'''
模型数据的序列化
'''
from weather.models import CityNumber, WeatherLive
from rest_framework import serializers
from weather.api import DynamicFieldsSerializerMixin


class CityNumberSerializer(serializers.ModelSerializer):
    ''''''
    class Meta:
        model = CityNumber
        fields = '__all__'


class WeatherLiveSerializer(DynamicFieldsSerializerMixin, serializers.ModelSerializer):
    ''''''
    __str__ = serializers.CharField(read_only=True)

    class Meta:
        model = WeatherLive
        fields = '__all__'
        read_only_fields = ['wind_level']  # 在api界面不允许修改的字段